﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Admin_MasterPage : System.Web.UI.MasterPage
{
    myDataSetTableAdapters.AccountsTableAdapter accAdapter = new myDataSetTableAdapters.AccountsTableAdapter();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["login"] == null)
        {
            Response.Redirect("login.aspx");
        }
        lbluserNameAdmin.Text = Session["userName"].ToString();
        getCurrenSideBarItem();
        myDataSet.AccountsDataTable accTable = accAdapter.GetDataConvertByStatusType();
        lblRequest.Text = accTable.Rows.Count.ToString();
    }

    protected void getCurrenSideBarItem()
    {
        string url = Request.ServerVariables["URL"].ToString();
        url = url.Substring(27, url.Length - 32);
        resetCssClass();
        if (url == "seminar")
        {
            titleSem.CssClass = "nav-top-item current";
            seminar.CssClass = "current";
        }
        if (url == "survey_category")
        {
            titleSur.CssClass = "nav-top-item current";
            survey_category.CssClass = "current";
        }
        if (url == "survey")
        {
            titleSur.CssClass = "nav-top-item current";
            survey.CssClass = "current";
        }
        if (url == "survey_question")
        {
            titleSur.CssClass = "nav-top-item current";
            survey_question.CssClass = "current";
        }
        if (url == "survey_result")
        {
            titleSur.CssClass = "nav-top-item current";
            survey_result.CssClass = "current";
        }
        if (url == "competition")
        {
            titleCom.CssClass = "nav-top-item current";
            competition.CssClass = "current";
        }
        if (url == "post")
        {
            titleCom.CssClass = "nav-top-item current";
            post.CssClass = "current";
        }
        if (url == "question_type")
        {
            titleQues.CssClass = "nav-top-item current";
            question_type.CssClass = "current";
        }
        if (url == "question")
        {
            titleQues.CssClass = "nav-top-item current";
            question.CssClass = "current";
        }
        if (url == "answer")
        {
            titleQues.CssClass = "nav-top-item current";
            answer.CssClass = "current";
        }
        if (url == "account")
        {
            titleAcc.CssClass = "nav-top-item current";
            account.CssClass = "current";
        }
        if (url == "account_request")
        {
            titleAcc.CssClass = "nav-top-item current";
            account_request.CssClass = "current";
        }
        if (url == "faq")
        {
            titleFaq.CssClass = "nav-top-item current";
            faq.CssClass = "current";
        }
    }

    protected void resetCssClass()
    {
        titleSem.CssClass = "nav-top-item ";
        titleSur.CssClass = "nav-top-item ";
        titleCom.CssClass = "nav-top-item ";
        titleQues.CssClass = "nav-top-item ";
        titleAcc.CssClass = "nav-top-item ";
        titleFaq.CssClass = "nav-top-item ";
        seminar.CssClass = "na";
        survey_category.CssClass = "na";
        survey.CssClass = "na";
        survey_question.CssClass = "na";
        survey_result.CssClass = "na";
        competition.CssClass = "na";
        post.CssClass = "na";
        question_type.CssClass = "na";
        question.CssClass = "na";
        answer.CssClass = "na";
        account.CssClass = "na";
        account_request.CssClass = "na";
        faq.CssClass = "na";
    }
    protected void signOut_Click(object sender, EventArgs e)
    {
        Session["id"] = null;
        Session["userName"] = null;
        Session["login"] = null;
        Response.Redirect("login.aspx");
    }
}
